package com.threeti.mecool.legacy.infrastructure.persistence;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import com.threeti.mecool.legacy.domain.model.basicdata.biz.SalesLegacy;

public interface SalesLegacyRepository extends JpaRepository<SalesLegacy, String>, JpaSpecificationExecutor<SalesLegacy> {

	
	@Query(nativeQuery=true,value="select t.projstore_id "+
							       " from DM_PROJECT_SALESPROMOTER_STORE t "+
							       " where t.projsales_id in (select t.id "+
							      					   "        from DM_PROJECT_SALESPROMOTER t "+
							      					   "       where t.sales_promoter = ?2 "+
							      					   "         and t.project = ?3 )    "  +
							      					   " 		 and t.projstore_id in ( ?1 ) ")
	List<String> filterStoreIdsBySaleAssigned(List<String> storeCodes,String saleId, long projectId);
}
